using System.Text;
using System.Text.Json;

public class TaskPoster
{
    private readonly HttpClient _httpClient;

    public TaskPoster()
    {
        _httpClient = new HttpClient();
    }

    public async Task<HttpResponseMessage> PostJsonAsync<T>(string url, T data, CancellationToken cancellationToken = default)
    {
        var json = JsonSerializer.Serialize(data);
        var content = new StringContent(json, Encoding.UTF8, "application/json");
        return await _httpClient.PostAsync(url, content, cancellationToken);
    }
}